home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 2585 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.5 KB  |  58 lines

  1. Path: newsbf02.news.aol.com!not-for-mail
  2. From: manorton@aol.com (MANorton)
  3. Newsgroups: comp.lang.c++
  4. Subject: Getting Free Disk Space
  5. Date: 18 Jan 1996 11:16:10 -0500
  6. Organization: America Online, Inc. (1-800-827-6364)
  7. Sender: root@newsbf02.news.aol.com
  8. Message-ID: <4dlroa$dvr@newsbf02.news.aol.com>
  9. Reply-To: manorton@aol.com (MANorton)
  10. NNTP-Posting-Host: newsbf02.mail.aol.com
  11.  
  12. I couldn't figure out a way to get the amount for getting free disk space
  13. on a disk from VB so I wrote a DLL. Everything is fine in VC but when I
  14. run it from VB I get an out of memory error. Can anyone tell me what's
  15. wrong or is there a better way to do this?
  16.  
  17.  
  18. /* free disk space DLL */
  19.  
  20. #include <windows.h>
  21. #include <dos.h>
  22.                                             
  23. long FAR PASCAL FreeDiskSpace (int cDrive)
  24. {
  25.     struct  _diskfree_t drive;
  26.               long lFreeDiskSpace = -1;
  27.     unsigned iDrv = 0;    
  28.         
  29.     if (('A' <= cDrive) && (cDrive <= 'Z'))  iDrv = cDrive - 'A';
  30.     if (('a' <= cDrive) && (cDrive <= 'z'))  iDrv = cDrive - 'a';
  31.        
  32.       /* Get information on disk specified by cDrive or default disk
  33. drive 0 */
  34.     if (! _dos_getdiskfree( iDrv, &drive ))
  35.         lFreeDiskSpace = (drive.avail_clusters * 
  36. drive.sectors_per_cluster * drive.bytes_per_sector) / 1024;
  37.         
  38.     return lFreeDiskSpace;
  39. }
  40.  
  41.  
  42.  
  43. int FAR PASCAL LibMain (HANDLE hInstance, WORD wDataSeg, WORD wHeapSize,
  44. LPSTR lpszCmdLine)
  45. {
  46.     if (wHeapSize > 0)    
  47.         UnlockData (0);
  48.     return (0);
  49. }                      
  50.  
  51. void FAR PASCAL WEP (int nParameter)
  52. {
  53.     return;
  54. }
  55.  
  56.  
  57.                                                    M
  58.